package com.ruoyi.vehicle.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.vehicle.domain.TbInterval;
import com.ruoyi.vehicle.service.ITbIntervalService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 派单间隔设置Controller
 * 
 * @author ruoyi
 * @date 2025-08-18
 */
@RestController
@RequestMapping("/interval")
public class TbIntervalController extends BaseController
{
    @Autowired
    private ITbIntervalService tbIntervalService;

    /**
     * 查询派单间隔设置列表
     */
    //@RequiresPermissions("vehicle:interval:list")
    @GetMapping("/list")
    public TableDataInfo list(TbInterval tbInterval)
    {
        startPage();
        List<TbInterval> list = tbIntervalService.selectTbIntervalList(tbInterval);
        return getDataTable(list);
    }

    /**
     * 导出派单间隔设置列表
     */
    //@RequiresPermissions("vehicle:interval:export")
    @Log(title = "派单间隔设置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbInterval tbInterval)
    {
        List<TbInterval> list = tbIntervalService.selectTbIntervalList(tbInterval);
        ExcelUtil<TbInterval> util = new ExcelUtil<TbInterval>(TbInterval.class);
        util.exportExcel(response, list, "派单间隔设置数据");
    }

    /**
     * 获取派单间隔设置详细信息
     */
    //@RequiresPermissions("vehicle:interval:query")
    @GetMapping(value = "/{intervalId}")
    public AjaxResult getInfo(@PathVariable("intervalId") Long intervalId)
    {
        return success(tbIntervalService.selectTbIntervalByIntervalId(intervalId));
    }

    /**
     * 新增派单间隔设置
     */
    //@RequiresPermissions("vehicle:interval:add")
    @Log(title = "派单间隔设置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbInterval tbInterval)
    {
        return toAjax(tbIntervalService.insertTbInterval(tbInterval));
    }

    /**
     * 修改派单间隔设置
     */
    //@RequiresPermissions("vehicle:interval:edit")
    @Log(title = "派单间隔设置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbInterval tbInterval)
    {
        return toAjax(tbIntervalService.updateTbInterval(tbInterval));
    }

    /**
     * 删除派单间隔设置
     */
    //@RequiresPermissions("vehicle:interval:remove")
    @Log(title = "派单间隔设置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{intervalIds}")
    public AjaxResult remove(@PathVariable Long[] intervalIds)
    {
        return toAjax(tbIntervalService.deleteTbIntervalByIntervalIds(intervalIds));
    }
}
